<%--
  Created by IntelliJ IDEA.
  User: 骆鹏
  Date: 2017/7/26
  Time: 10:43
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="fmt" uri="http://www.springframework.org/tags" %>
<!DOCTYPE html>
<html>
<head>
    <title>考核项目设定</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <link rel="stylesheet" href="/css/officialDocument/officialDocument.css">

    <link rel="stylesheet" href="/lib/layer/skin/default/layer.css">
    <link type="text/css" rel="stylesheet" href="/lib/pagination/style/pagination.css">
    <link rel="stylesheet" href="/css/base/base.css?20201106.1">

    <script src="/js/common/language.js"></script>

    <script type="text/javascript" src="/js/jquery/jquery-1.9.1.js"></script>
    <script src="/js/jquery/jquery.cookie.js"></script>
    <script type="text/javascript" src="/js/base/tablePage.js"></script>
    <script src="/lib/layer/layer.js?20201106"></script>
    <script src="/js/base/base.js"></script>
    <script src="/lib/laydate/laydate.js"></script>
    <script type="text/javascript" charset="utf-8" src="/lib/pagination/js/jquery.pagination.min.js"></script>

<%--<script src="/js/document/makeADraft.js"></script>--%>
    <link rel="stylesheet" type="text/css" href="/css/commonTheme/${sessionScope.InterfaceModel}/commonTheme.css"/>
    <style>

        table tr {
            border-width: 1px;
            border-style: solid;
            border-color: rgb(204, 204, 204);
            border-image: initial;
        }
        table tr th {
            font-size: 13pt;
            color: rgb(47, 92, 143);
            text-align: center;
            padding: 6px;
        }

        table  td {
            font-size: 11pt;
            padding: 6px;
            height: 30px;
            line-height: 30px;
            text-align: center;
            word-break: keep-all;
            white-space: nowrap;
            text-overflow: ellipsis;
            overflow: hidden;
        }
        table tr:nth-child(2n) {
            background-color: rgb(255, 255, 255);
        }
        table tr:nth-child(2n+1) {
            background-color:#F6F7F9 ;
        }
        .newLeave {
            border-radius: 3px;
            margin-right: 3%;
            float: right;
            width: 70px;
            height: 28px;
            color: #fff;
            font-size: 14px;
            line-height: 28px;
            margin-right: 3%;
            margin-top: 14px;
            cursor: pointer;
            background: #2b7fe0
        }
        .clearfix {
            margin: 5px auto;
            width: 93%;
        }
        .clearfix a{
            color: #007cfd;
        }
        textarea.BigStatic {
            font-size: 10pt;
            padding: 1px 5px;
            border: 1px solid #C0BBB4;
            background: #E0E0E0;
            margin-left: 32px;
        }
        .index-desc{
            height: 95px;
            float: left;
            line-height: 95px;
            margin-right: 3px;
        }
        .lab-set{
            height: 50px;
            float: left;
            line-height: 47px;
            font-size: 14px;
        }

        #portalName{
            height: 30px;
            margin-right: 16px;
            margin-left: 10px;
            width: 305px;
        }
        .li-set p{
            margin: 5px 0 0 115px;
        }
        .M-box3 .active {
            margin: 0px 3px;
            width: 38px;
            height: 38px;
            line-height: 38px;
            background: #2b7fe0;
            font-size: 12px;
            border: 1px solid #2b7fe0;
            color: #fff;
            text-align: center;
            display: inline-block;
        }
        .M-box3 {
            margin-top: 30px;
            position: fixed;
            bottom: 10px;
            right: 60px;
            text-align: center;
        }
        .M-box3 a {
            margin: 0 3px;
            width: 38px;
            height: 38px;
            line-height: 38px;
            font-size: 12px;
            display: inline-block;
            text-align: center;
            background: #fff;
            border: 1px solid #ebebeb;
            color: #333;
            text-decoration: none;
        }
        .jump-ipt {
            width: 38px;
            height: 38px;
            line-height: 38px;
            text-align: center;
            padding: 0;
        }
        .del{
            color: #e01919;
        }
        .clearfix  .orgClear{
            color: #e01919;
        }
    </style>
</head>
<body>
<div class="headTop" id="maintop">
    <div class="headImg">
        <img src="/img/kaohesheding.png" alt="">
    </div>
    <div class="divTitle">
        考核试卷
    </div>
    <%--<input type="submit" value="新建" id="newBtn1" class="btn">--%>
    <div class="newLeave" id="busTravelData" >
        <span style="margin-left: 26px;" id="newBtn1" class="btn">
            <img style="margin-right: 4px;margin-left: -16px;margin-bottom: 2px;" src="../../img/mywork/newbuildworjk.png" >
            新建</span>
    </div>
</div>




<table style="margin:65px auto;width:95%" >
    <thead>
        <tr style="background: none">
            <th>考核试卷名称</th>
            <th>考核试卷描述</th>
            <th>关联任务</th>
            <th style="width: 32%">操作</th>
        </tr>
    </thead>
    <tbody id="kaohe">

    </tbody>
</table>
<div id="dbgz_page" class="M-box3">

</div>

<script>

    $('table').on('click', '.personXiang', function () {

        var typeId = $(this).parent().parent().attr('fenlei')

    });
    //新建
    $('#busTravelData').click(function () {
        layer.open({
            type: 1,
            title: ['新建考核指标集', 'background-color:#2b7fe0;color:#fff;'],
            area: ['600px', '450px'],
            shadeClose: false, //点击遮罩关闭
            content:
            '<form id="saveRule" class="layui-form">' +
            '<div class="inputlayout">' +
            '<ul>' +
            '<li class="clearfix">' +
            '<label><span style="color:#e4393c">*</span> 考核指标集名称：</label><input id="portalName" type="text" name="portalName" value="" maxlength="25">(最多输入25个字)' +
            '</li>' +
            '<li class="clearfix li-desc">' +
            '<label class="index-desc">考核指标集描述：</label><textarea class="text-desc" name="portalMark" id="portalMark" cols="48" rows="5" style="margin-left:16px"></textarea>' +
            '</li>' +
            '<li class="clearfix">' +
            '<label>设定考核依据模块：</label><input id="sortNo" type="checkbox" name="sortNo" value="DIARY"><label for="sortNo" class="theLog">个人工作日志</label><input id="sortNo1" type="checkbox" name="sortNo" value="CALENDAR"><label for="sortNo1" class="theLog">个人日程安排</label>' +
            '</li>' +
            '<li class="clearfix li-set">' +
            '<label class="lab-set"> 按部门设置：</label><textarea cols=40 name="USER_NAME" rows=2 class="BigStatic" id="deptNames" wrap="yes" readonly></textarea>\n' +
            '        <a href="javascript:;" class="orgAdd  addDept release3 ">添加</a>\n' +
            '        <a href="javascript:;" class="orgClear release3 clearDept">清空</a>\n' +
            '</li>' +
            '<li class="clearfix li-set">' +
            '<label class="lab-set"> 按人员设置：</label><textarea cols=40 name="USER_NAME" rows=2 class="BigStatic" id="query_toId" wrap="yes" readonly></textarea>\n' +
            '        <a href="javascript:;" class="orgAdd release3 " id="personnel">添加</a>\n' +
            '        <a href="javascript:;" class="orgClear release4 empty" >清空</a>\n' +
            '</li>' +
            '<li class="clearfix li-set">' +
            '<label class="lab-set"> 按角色设置：</label><textarea cols=40 name="USER_NAME" rows=2 class="BigStatic" id="userPrivInput" wrap="yes" readonly></textarea>\n' +
            '        <a href="javascript:;" class="orgAdd userPrivAdd">添加</a>\n' +
            '        <a href="javascript:;" class="orgClear userPrivClear">清空</a>\n  <p> <span style="color: #e4393c">*</span>考核指标集使用范围取部门、人员和角色的并集</p>' +

            '</li>' +

            '</ul>' +
            '</div>' +
            '</form>',
            btn: ['保存', '取消'],
            btn1: function (index) {
                if ($('#portalName').val() == '') {
                    layer.msg('请填写考核指标集名称', {icon: 6});
                    return false;
                }
                if ($('#portalMark').val() == '') {
                    layer.msg('请填写考核指标集描述', {icon: 6});
                    return false;
                }
                if ($('#fenlei').val() == '') {
                    layer.msg('请选择指标集分类', {icon: 6});
                    return false;
                }
                var groupRefer = '';

                $('input:checkbox:checked').each(function () {
                    groupRefer+=$(this).val()+",";
                });
                $.ajax({
                    type: 'post',
                    url: '/ScoreGroupLeader/addScoreGroup',
                    dataType: 'json',
                    data: {
                        groupName: $('#portalName').val(),
                        groupDesc: $('#portalMark').val(),
                        toId: $('#deptNames').val(),
                        privId: $('#query_toId').val(),
                        userId: $('#userPrivInput').val(),
                        groupDesc: $('#portalMark').val(),
                        groupRefer: groupRefer,
                        /*sortNo: $('#sortNo1').val()*/
                    },
                    success: function () {

                        layer.msg("保存成功", {
                            icon: 1,
                            time: 1500 //2秒关闭（如果不配置，默认是3秒）
                        }, function () {
                            location.reload();
                        });
                    }
                });
            },
            success:function () {
                // 添加部门信息
                $(".addDept").on("click", function () {
                    dept_id = "deptNames";
                    $.popWindow("/common/selectDept");
                });
                // 清空部门信息
                $('.clearDept').click(function () {
                    $('#deptNames').attr("deptid", "");
                    $('#deptNames').attr("deptno", "");
                    $('#deptNames').attr("deptname", "");
                    $('#deptNames').val("");
                });


                /* 选人控件 */
                $("#personnel").on("click",function(){
                    user_id = "query_toId";
                    $.popWindow("/common/selectUser");
                });
                // 清空用户信息
                $('.empty').click(function () {
                    $("#query_toId").val("");
                    $("#query_toId").attr('username','');
                    $("#query_toId").attr('dataid','');
                    $("#query_toId").attr('user_id','');
                    $("#query_toId").attr('userprivname','');
                });

                // 获取角色信息控件
                $(".userPrivAdd").on("click",function(){
                    priv_id="userPrivInput";
                    $.popWindow("/common/selectPriv");
                });
                // 清空角色信息
                $('.userPrivClear').click(function () {
                    $('#userPrivInput').attr("privid","");
                    $('#userPrivInput').attr("userpriv","");
                    $('#userPrivInput').val("");
                });


            }
        })
    });
    //列表带分页
    function undefindData(data) {
        if(data == undefined){
            return '';
        }else{
            return data;
        }
    }
    function inputcheck(name,value) {
        $('#'+name+'').val(value)
    }
    var ajaxPageTr={
        data:{
            page:1,//当前处于第几页
            pageSize:5,//一页显示几条
            useFlag:true,
            typeId:0
            // computationNumber:null
        },
        page:function () {
            var me=this;
            layer.msg('加载中', {
                icon: 16
                ,shade: 0.01
            });
            $.ajax({
                type:'get',
                url:'/ScoreGroupLeader/selScoreGroup',
                dataType:'json',
                data:me.data,
                success:function(res){
                    if(res){
                        var str='';
                        $.each(res.obj, function (index, item) {
                            var display = '';
                            if(item.editFlag!=undefined&&!item.editFlag){
                                display = 'display:none';
                            }
                            str += '<tr groupId="'+item.groupId+'">' +
                                '<td title="'+item.groupName +'">' + item.groupName + '</td>' +
                                '<td title="'+item.groupDesc+'">' + item.groupDesc+ '</td>' +
                                '<td title="'+undefindData(item.flowName) +'">' + undefindData(item.flowName) + '</td>' +
                                '<td>' +
                                '<a class="mingxi" href="javascript:;" style="margin-right: 10px;'+display+'">指标集明细</a>' +
                                '<a class="bianji" href="javascript:;" style="margin-right: 10px;'+display+'">修改</a>' +
                                '<a class="del" href="javascript:;" style="margin-right: 10px;'+display+'">删除</a>' +
                                '<a class="clone" href="javascript:;" style="margin-right: 10px;">克隆</a><a class="xiangqing" href="javascript:;" style="margin-right: 10px;">查看详情</a></td>' +
                                '</tr>';

                        })
                        $('#kaohe').html(str)
                        layer.closeAll();
                        me.pageTwo(res.totleNum,me.data.pageSize,me.data.page)
                    }else{

                    }

                }
            })

        },
        pageTwo:function (totalData, pageSize,indexs) {
            var mes=this;
            $('#dbgz_page').pagination({
                totalData: totalData,
                showData: pageSize,
                prevContent:'上一页',
                nextContent:'下一页',
                jump: true,
                coping: true,
                homePage:'',
                endPage: '',
                current:indexs||1,
                callback: function (index) {
                    mes.data.page=index.getCurrent();
                    mes.page();
                }
            });
        }
    }
    ajaxPageTr.page();
    //删除
    $('table').on('click','.del',function(){
        var groupId=$(this).parent().parent().attr('groupId')
        layer.open({
            type: 1,
            title: ['提示','background-color:#2e8ded;color:#fff'],
            content:'<div style="text-align: center;margin-top: 18px;">确认删除吗？</div>',
            area: ['200px', '160px'],
            btn: ['确认','取消'],
            yes:function(index){
                $.ajax({
                    url:'/ScoreGroupLeader/delScoreGroupById',
                    type:'post',
                    data:{
                        'groupId':groupId,
                    },
                    dataType:'json',

                    success:function(res){
                        if(res.flag==true){
                            layer.msg("删除成功",{
                                icon: 1,
                                time: 1500 //2秒关闭（如果不配置，默认是3秒）
                            },function(){
                                location.href="/ScoreGroupLeader/scoreGroup"
                            })
                        }else {
                            layer.msg("删除失败",{
                                icon: 2,
                                time: 1500 //2秒关闭（如果不配置，默认是3秒）
                            },function(){
                                location.href="/ScoreGroupLeader/scoreGroup"
                            })
                        }
                    }
                })
            },
            btn2: function (index) {
                layer.close(index)
            },
            btnAlign:'c',

        })
    });
    //明细
    $('table').on('click','.mingxi',function(){
        var groupId=$(this).parent().parent().attr('groupId');
        window.location.href='/ScoreItemLeader/assessmentmingxi?groupId='+groupId;
    });
    //详情
    $('table').on('click','.xiangqing',function(){
        var groupId=$(this).parent().parent().attr('groupId');
        window.location.href='/ScoreItemLeader/assessmentmingxi?flag=detail&groupId='+groupId;
    });
    //克隆
    $('table').on('click','.clone',function(){
        var groupId=$(this).parent().parent().attr('groupId')
        $.ajax({
            url:'/ScoreGroupLeader/cloneScoreGroup',
            type:'post',
            data:{
                groupId:groupId
            },
            dataType:'json',
            success:function(res){
                if(res.flag==true){
                    layer.msg("克隆成功", {
                        icon: 1,
                        time: 1500 //2秒关闭（如果不配置，默认是3秒）
                    }, function () {
                        location.reload();
                    });
                }else{
                    layer.msg("克隆失败", {icon: 2})
                }
            }
        })
    });
    //编辑
    $('table').on('click','.bianji',function(){
        var groupId=$(this).parent().parent().attr('groupId');
        layer.open({
            type: 1,
            title: ['修改考核指标集', 'background-color:#2b7fe0;color:#fff;'],
            area: ['600px', '450px'],
            shadeClose: false, //点击遮罩关闭
            content:
            '<form id="saveRule" class="layui-form">' +
            '<div class="inputlayout">' +
            '<ul>' +
            '<li class="clearfix">' +
            '<label><span style="color:#e4393c">*</span> 考核指标集名称：</label><input id="portalName" type="text" name="portalName" value="" maxlength="25">(最多输入25个字)' +
            '</li>' +
            '<li class="clearfix li-desc">' +
            '<label class="index-desc">考核指标集描述：</label><textarea class="text-desc" name="portalMark" id="portalMark" cols="48" rows="5" style="margin-left: 16px"></textarea>' +
            '</li>' +
            '<li class="clearfix li-set">' +
            '<label class="lab-set"> 按部门设置：</label><textarea cols=40 name="USER_NAME" rows=2 class="BigStatic" id="deptNames" wrap="yes" readonly></textarea>\n' +
            '        <a href="javascript:;" class="orgAdd  addDept release3 ">添加</a>\n' +
            '        <a href="javascript:;" class="orgClear release3 clearDept">清空</a>\n' +
            '</li>' +
            '<li class="clearfix li-set">' +
            '<label class="lab-set"> 按人员设置：</label><textarea cols=40 name="USER_NAME" rows=2 class="BigStatic" id="query_toId" wrap="yes" readonly></textarea>\n' +
            '        <a href="javascript:;" class="orgAdd release3 " id="personnel">添加</a>\n' +
            '        <a href="javascript:;" class="orgClear release4 empty" >清空</a>\n' +
            '</li>' +
            '<li class="clearfix li-set">' +
            '<label class="lab-set"> 按角色设置：</label><textarea cols=40 name="USER_NAME" rows=2 class="BigStatic" id="userPrivInput" wrap="yes" readonly></textarea>\n' +
            '        <a href="javascript:;" class="orgAdd userPrivAdd">添加</a>\n' +
            '        <a href="javascript:;" class="orgClear userPrivClear">清空</a>\n  <p> <span style="color: #e4393c">*</span>考核指标集使用范围取部门、人员和角色的并集</p>' +

            '</li>' +

            '</ul>' +
            '</div>' +
            '</form>',
            btn: ['保存', '取消'],
            success:function (index) {

                $.ajax({
                    type: 'post',
                    url: '/ScoreGroupLeader/selScoreGroup',
                    dataType: 'json',
                    data: {
                        groupId:groupId
                    },
                    success: function (res) {
                        var objs=  res.obj[0]
                        inputcheck('portalName',objs.groupName)
                        inputcheck('portalMark',objs.groupDesc)
                        inputcheck('deptNames',objs.toId)
                        inputcheck('query_toId',objs.privId)
                        inputcheck('userPrivInput',objs.userId)
                    }
                });
                $(".addDept").on("click", function () {
                    dept_id = "deptNames";
                    $.popWindow("/common/selectDept");
                });
                // 清空部门信息
                $('.clearDept').click(function () {
                    $('#deptNames').attr("deptid", "");
                    $('#deptNames').attr("deptno", "");
                    $('#deptNames').attr("deptname", "");
                    $('#deptNames').val("");
                });
                $("#personnel").on("click",function(){
                    user_id = "query_toId";
                    $.popWindow("/common/selectUser");
                });
                $('.orgClear').click(function () {
                    $("#query_toId").val("");
                    $("#query_toId").attr('username','');
                    $("#query_toId").attr('dataid','');
                    $("#query_toId").attr('user_id','');
                    $("#query_toId").attr('userprivname','');
                });

                // 获取角色信息控件
                $(".userPrivAdd").on("click",function(){
                    priv_id="userPrivInput";
                    $.popWindow("/common/selectPriv");
                });
                // 清空角色信息
                $('.userPrivClear').click(function () {
                    $('#userPrivInput').attr("privid","");
                    $('#userPrivInput').attr("userpriv","");
                    $('#userPrivInput').val("");
                });
            },
            btn1: function (index) {
                if ($('#portalName').val() == '') {
                   layer.msg('请填写考核指标集名称', {icon: 6});
                   return false;
               }
               if ($('#portalMark').val() == '') {
                   layer.msg('请填写考核指标集描述', {icon: 6});
                   return false;
               }
                var groupName = $('#portalName').val()
                var groupDesc = $('#portalMark').val()
                var deptNames = $('#deptNames').val()
                var query_toId = $('#query_toId').val()
                var userPrivInput = $('#userPrivInput').val()
                $.ajax({
                    type: 'post',
                    url: '/ScoreGroupLeader/modifyScoreGroup',
                    dataType: 'json',
                    data: {
                        groupId:groupId,
                        groupName: groupName,
                        groupDesc: groupDesc,
                        toId:deptNames,
                        privId:query_toId,
                        userId:userPrivInput
                    },
                    success: function () {
                        layer.msg("修改成功", {
                            icon: 1,
                            time: 1500 //2秒关闭（如果不配置，默认是3秒）
                        }, function () {
                            window.location.href='/ScoreGroupLeader/scoreGroup';
                        });
                    }
                });
            }
        })
    });
</script>
</body>
</html>
